<template>
	<el-container class="center">
		<!--头部导航-->
		<el-header style="padding: 0;">
			<nav-header></nav-header>
		</el-header>
		
		<!--主体内容-->
		<el-main>
			<keep-alive  v-if="isRouterAlive">
				<router-view v-wechat-title="$route.meta.networkTitle" ></router-view>
			</keep-alive>
			<!-- <router-view v-if="isRouterAlive&&!this.$router.history.current.meta.keepAlive"   v-wechat-title="$route.meta.title" /> -->
		</el-main>
	</el-container>
</template>

<script>
import { mapActions, mapGetters } from 'vuex';
import NavHeader from '../header/NavHeader';
//非父子组件传值
import bus from '../../../static/js/bus.js';

export default {
	components: {
		NavHeader
	},
	computed: {
		...mapGetters(['windowSize','userInfo', 'api']),//获取
	},
	data() {
		return {
			isSideEdge:true,
			isRouterAlive:true,//刷新主体
		};
	},
	mounted() {
		let that = this;
		//刷新主体
		bus.$off('refreshPage')
		bus.$on('refreshPage',(res)=>{
			that.isRouterAlive=false
			that.$nextTick(()=>{
				that.isRouterAlive=true
			})
		})
		//监听窗口
		that.listeningWindow()
	},
	methods: {
		...mapActions(['set_window_size']),
		//监听窗口
		listeningWindow(){
			let that = this;
			//监听窗口大小
			window.onresize = () => {
				return (() => {
					window.screenWidth = document.body.clientWidth;
					//提交到state
					that.set_window_size(window.screenWidth);
				})();
			};
			//获取当前窗口大小
			console.log('aaa', window.innerWidth);
			//提交到state
			that.set_window_size(window.innerWidth);
			
		},
		
		
	}
};
</script>
<style scoped="scoped">
.center{height: 100%;}
/* 头部 */
.lz-header{
	text-align: right; font-size: 12px ;padding: 0 10px;
}
.el-header {
	border-bottom: solid 1px #e6e6e6;
	color: #333;
	line-height: 60px;
}
.el-main {padding: 15px;background:#f2f2f2;}
</style>
